package driver.ui.driver;

import java.util.ArrayList;

import driver.ui.R;
import driver.ui.driver.Adapter.ActionlistAdapter;
import driver.ui.driver.Adapter.ContactlistAdapter;
import driver.ui.driver.Beans.action;
import driver.ui.driver.Beans.person;
import driver.ui.driver.ListPopulate.Populatelist;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

public class Contactavailable extends Activity {
	ListView actionList;
	ActionlistAdapter arrayAdapter;
	TextView contactname;
	 @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.contactavailable);
	        Bundle extras = getIntent().getExtras();
			String name = extras.getString("name");			
	        actionList = (ListView) findViewById(R.id.actionList);
	        contactname=(TextView)findViewById(R.id.availablename);
	        contactname.setText(name);
	        
	        ArrayList<action>   actionlist= new ArrayList<action>();

	        //Initialize our array adapter notice how it references the contactlistitems.xml layout
	        arrayAdapter = new ActionlistAdapter(Contactavailable.this, R.layout.actionitems,actionlist);
	        //Add actions
			action ac1=new action();
		    ac1.setImgsrc(R.drawable.meeting);
		    ac1.setName("Set up meeting");
		    actionlist.add(ac1);
		    action ac2=new action();
		    ac2.setImgsrc(R.drawable.pickup);
		    ac2.setName("Set up pickup");
		    actionlist.add(ac2);
		    action ac3=new action();
		    ac3.setImgsrc(R.drawable.call);
		    ac3.setName("Call Back");
		    actionlist.add(ac3);
		    action ac4=new action();
		    ac4.setImgsrc(R.drawable.sms);
		    ac4.setName("Send text message");
		    actionlist.add(ac4);
		    action ac5=new action();
		    ac5.setImgsrc(R.drawable.voicemail);
		    ac5.setName("Leave voicemail");
		    actionlist.add(ac5);
		    action ac6=new action();
		    ac6.setImgsrc(R.drawable.share);
		    ac6.setName("Share Status");
		    actionlist.add(ac6);
		    action ac7=new action();
		    ac7.setImgsrc(R.drawable.clock);
		    ac7.setName("Close");
		    actionlist.add(ac7);
	 

	        
	        //Set the above adapter as the adapter of choice for our list
	        actionList.setAdapter(arrayAdapter);
	        //ListView's Listener
	        actionList.setOnItemClickListener(new OnItemClickListener(){

				@Override
				public void onItemClick(AdapterView<?> arg0, View arg1,
						int position, long arg3) {
					// TODO Auto-generated method stub
					Object listItem = actionList.getItemAtPosition(position);
					action ac=(action)listItem;
					String name=ac.getName();
					if(name.equals("Set up pickup"))
					{
						
						Intent intent=new Intent();
						intent.setAction("Pickupsettings");
						intent.putExtra("name",contactname.getText().toString());
						startActivity(intent);
						
					}
				}
	        });
	        
	       	
	        
	 }


}
